package com.zbkj.front.controller.v2;

import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.front.model.vo.PickupTimeAvailableCheckVO;
import com.zbkj.front.model.vo.PickupTimeVO;
import com.zbkj.front.service.FrontExpressService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/v2/express")
public class ExpressController {

    @Autowired
    private FrontExpressService frontExpressService;

    @GetMapping("/city/pickup/time/available")
    @ApiOperation(value = "获取城市的可预约上门时间", tags = "快递服务")
    public CommonResult<PickupTimeVO> getInusePickupTimeList(@RequestParam("userAddressId") Integer userAddressId) {
        return CommonResult.success(frontExpressService.getAvailablePickupTimeOfCity(userAddressId));
    }

    @GetMapping("/city/pickup/time/check")
    @ApiOperation(value = "检查揽件时间是否可用", tags = "快递服务")
    public CommonResult<PickupTimeAvailableCheckVO> getInusePickupTimeList(@RequestParam("userAddressId") Integer userAddressId,
                                                                           @RequestParam("sendTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime sendTime) {
        return CommonResult.success(frontExpressService.checkAvailablePickupTimeOfCity(userAddressId, sendTime));
    }

}